package Machine;



import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;

import Monitoring_Machine.*;



public class MachineServante extends MachineASurveillerPOA{
	
	
	private Hashtable seuils_cpu= new Hashtable();
	private Hashtable seuils_mem= new Hashtable();
	private Hashtable seuils_Disk= new Hashtable();

    private Machine machine_locale;
	
	public MachineServante(Machine machine_locale)
	{
		this.machine_locale=machine_locale;
		machine_locale.setConnecte(true);
	}
	
	
	
	public Diagnostic test_machine(Type_commande commande, String nomMachine)
	{
		Commande cmd = new Commande(machine_locale);
		if (commande==Type_commande.cpu)
		{
			if (seuils_cpu.get(nomMachine)!=null)
			return cmd.executer_cmd(commande, Integer.parseInt(seuils_cpu.get(nomMachine).toString()));
			else return cmd.executer_cmd(commande, machine_locale.getSeuil_cpu());
		}
		else if (commande==Type_commande.mem)
		{
			if (seuils_mem.get(nomMachine)!=null)
			return cmd.executer_cmd(commande, Integer.parseInt(seuils_mem.get(nomMachine).toString()));
			else return cmd.executer_cmd(commande, machine_locale.getSeuil_mem());
		}
		else return cmd.executer_cmd(commande, 0);
		
	}
	
	
	public Hashtable getSeuils_cpu() {
		return seuils_cpu;
	}



	public void setSeuils_cpu(Hashtable seuilsCpu) {
		seuils_cpu = seuilsCpu;
	}



	public Hashtable getSeuils_mem() {
		return seuils_mem;
	}



	public void setSeuils_mem(Hashtable seuilsMem) {
		seuils_mem = seuilsMem;
	}



	public Hashtable getSeuils_Disk() {
		return seuils_Disk;
	}



	public void setSeuils_Disk(Hashtable seuilsDisk) {
		seuils_Disk = seuilsDisk;
	}



	public Machine getMachine_locale() {
		return machine_locale;
	}



	public void setMachine_locale(Machine machineLocale) {
		machine_locale = machineLocale;
	}



	public void fixer_seuil(Type_commande commande, int valeur, String nomMachine)
	{
		if (commande.value()==Type_commande._cpu) seuils_cpu.put(nomMachine, valeur);
		if (commande.value()==Type_commande._mem) seuils_mem.put(nomMachine, valeur);
		
	}


	
	


}
